package com.ruoyi.web.controller.rgpp;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.rgpp.domain.Jibenstudents;
import com.ruoyi.rgpp.service.IJibenstudentsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生基本信息Controller
 * 
 * @author ruoyi
 * @date 2022-06-13
 */
@Controller
@RequestMapping("/rgpp/informationstudents")
public class JibenstudentsController extends BaseController
{
    private String prefix = "rgpp/informationstudents";

    @Autowired
    private IJibenstudentsService jibenstudentsService;

    @RequiresPermissions("rgpp:informationstudents:view")
    @GetMapping()
    public String informationstudents()
    {
        return prefix + "/informationstudents";
    }

    /**
     * 查询学生基本信息列表
     */
    @RequiresPermissions("rgpp:informationstudents:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Jibenstudents jibenstudents)
    {
        startPage();
        List<Jibenstudents> list = jibenstudentsService.selectJibenstudentsList(jibenstudents);
        return getDataTable(list);
    }

    /**
     * 导出学生基本信息列表
     */
    @RequiresPermissions("rgpp:informationstudents:export")
    @Log(title = "学生基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Jibenstudents jibenstudents)
    {
        List<Jibenstudents> list = jibenstudentsService.selectJibenstudentsList(jibenstudents);
        ExcelUtil<Jibenstudents> util = new ExcelUtil<Jibenstudents>(Jibenstudents.class);
        return util.exportExcel(list, "学生基本信息数据");
    }

    /**
     * 新增学生基本信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存学生基本信息
     */
    @RequiresPermissions("rgpp:informationstudents:add")
    @Log(title = "学生基本信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Jibenstudents jibenstudents)
    {
        return toAjax(jibenstudentsService.insertJibenstudents(jibenstudents));
    }

    /**
     * 修改学生基本信息
     */
    @RequiresPermissions("rgpp:informationstudents:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        Jibenstudents jibenstudents = jibenstudentsService.selectJibenstudentsById(id);
        mmap.put("jibenstudents", jibenstudents);
        return prefix + "/edit";
    }

    /**
     * 修改保存学生基本信息
     */
    @RequiresPermissions("rgpp:informationstudents:edit")
    @Log(title = "学生基本信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Jibenstudents jibenstudents)
    {
        return toAjax(jibenstudentsService.updateJibenstudents(jibenstudents));
    }

    /**
     * 删除学生基本信息
     */
    @RequiresPermissions("rgpp:informationstudents:remove")
    @Log(title = "学生基本信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jibenstudentsService.deleteJibenstudentsByIds(ids));
    }
}
